iT邦幫忙

2021 iThome 鐵人賽

DAY 1
0

print 輸出指令

?print
Docstring:
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file:  a file-like object (stream); defaults to the current sys.stdout.
sep:   string inserted between values, default a space.
end:   string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
Type:      builtin_function_or_method
a=1
b=2
print (a,b,sep=',',end='')
print (a+b)

結果:

1,23

print ("%d + %d = %d"%(a,b,a+b))

1 + 2 = 3


金字塔程式

print ("  *")
print (" ***")
print ("*****")

結果

  *
 ***
*****

程式 :

chinese = int(input("請輸入國文成績: "))
math = int(input("請輸入數學成績: "))
english = int(input("請輸入英文成績: "))

結果:


請輸入國文成績: 2299

請輸入數學成績:22

請輸入英文成績: 22
你的成績總分為:2343

系列文
Python人工智慧吸星大法好吔!1
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言